import { defineStore } from 'pinia'
import { ref, computed, reactive } from 'vue'

export const useAuthStore =  defineStore('userAuth', {
	state: () => ({
		token: localStorage.getItem('token') || null,
		companyCode: localStorage.getItem('companyCode') || null,
		nickName: localStorage.getItem('nickName') || null,
		avatar: localStorage.getItem('avatar') || null,
		openid: localStorage.getItem('openid') || null
	}),
	actions: {
		setToken(token) {
			this.token = token;
			localStorage.setItem('token', token);
		},
		clearToken() {
			this.token = null;
			localStorage.removeItem('token');
		},
		setCode(data) {
			this.companyCode = data;
			localStorage.setItem('companyCode', data);
		},
		setNickName(data) {
			this.nickName = data;
			localStorage.setItem('nickName', data);
		},
		setAvatar(data) {
			this.avatar = data;
			localStorage.setItem('avatar', data);
		},
		setOpenid(data) {
			this.openid = data;
			localStorage.setItem('openid', data);
		},
	}
});

export const useglobal = defineStore('globl', () => {
	
	
	// 以下待删除
	const wssbaseUrl = 'wss://apilive-test.zsszyf.com/';
	const appid = 'wxeb1bd0bf8da723c7';//服务号的appid
	const tenantid = '';
	const videoKey = '';//h5的视频都是分享来的；进入页面会有一个key值要接收后续用于直播间绑定
	const backUrl = ''//记录要返回的路径
	const signature = ''
	return {
		appid,videoKey,backUrl,wssbaseUrl,tenantid,signature
	}
})